package goods;

import java.util.List;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class GoodsDaoImplTest {

	GoodsDaoImpl dao = new GoodsDaoImpl();
	
	@Before  // 前置運行
	public void testInsert() {
		Assert.assertTrue(dao.insert(new Goods(1,"毛衣",GoodsType.CLOTH,99,99)));
		Assert.assertTrue(dao.insert(new Goods(2,"毛褲",GoodsType.CLOTH,88,88)));
		Assert.assertTrue(dao.insert(new Goods(3,"可樂",GoodsType.DRINK,3,999)));
		Assert.assertTrue(dao.insert(new Goods(4,"麵包",GoodsType.FOOD,18,199)));
	}

	@Test
	public void testDeleteById() {
		Assert.assertTrue(dao.deleteById(1));
	}

	@Test
	public void testUpdate() {
		Assert.assertTrue(dao.update(new Goods(4,"雪糕",GoodsType.FOOD,80,100)));
	}

	@Test
	public void testSelectById() {
		Goods selectById = dao.selectById(3);
		System.out.println(selectById);
	}

	@After
	public void testSelectAll() {
		List<Goods> gs = dao.selectAll();
		gs.forEach(System.out::println);
	}

}
